#pragma once
#include<iostream>
#include<pthread.h>

namespace  LockModule
{
    class Mutex
    {
        public:
        Mutex()
        {
            pthread_mutex_init(&mutex,nullptr);
        }
        void lock()
        {
            int n = pthread_mutex_lock(&mutex);
            (void*)n;
        }
        void unlock()
        {
            int n = pthread_mutex_unlock(&mutex);
            (void*)n;
        }
        pthread_mutex_t* LockPtr()
        {
            return &mutex;
        }
        ~Mutex()
        {
            pthread_mutex_destroy(&mutex);
        }
        private:

        pthread_mutex_t mutex;
    };

    class LockGuard
    {
        public:
        LockGuard(Mutex &mtx) :_mtx(mtx)
        {
            _mtx.lock();
        }
        ~LockGuard()
        {
            _mtx.unlock();
        }
        private:
        Mutex _mtx;
    };
}